package com.tcs.teg.web.accounts;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import com.tcs.teg.domain.accounts.Account;
import com.tcs.teg.service.accounts.IAccountService;

@Controller
public class AccountsController {
	
	@Autowired
	IAccountService accountService;
	
	private static final Log logger = LogFactory.getLog(AccountsController.class);

	
	@RequestMapping(value = "/getAccountHolderNames", 
			method = RequestMethod.GET,
			headers="Accept=*/*" )     
	public @ResponseBody List<String> getAccountHolderNames(@RequestParam("term") String query) 
	{   
		if(logger.isDebugEnabled()){
			logger.debug("In AccountsController ...............................");
		}
		List<String> accountHolderNamesList = accountService.getAccountNames(query);		
		return accountHolderNamesList;     
	} 
	
	

	@RequestMapping(value = "/getAccountHolderNumbers", 
			method = RequestMethod.GET,
			headers="Accept=*/*" )     
	public @ResponseBody List<String> getAccountHolderNumbers(@RequestParam("term") String query) 
	{   		
		if(logger.isDebugEnabled()){
			logger.debug("In AccountsController ...............................");				
		}
		List<String> accountHolderNumbersList = accountService.getContactNumbers(query);
		return accountHolderNumbersList;     
	} 
}
